home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Pascal Super Library
/
Pascal Super Library (CW International)(1997).bin
/
DELPHI32
/
CALCULTR
/
MCALC
/
MCALC.ZIP
/
TestCalc.pas
< prev
next >
Wrap
Pascal/Delphi Source File
|
1996-07-25
|
2KB
|
61 lines
(*
TRY LAUNCHING A CALC, EX: 2+2 AND WITHOUT REMOVING THE RESULT WINDOW (DON'T PRESS
ok, LAUNCH ANOTHER CALCULATION...MULTITHREAD IS REALLY USEFUL! You'll never wait
until a calculation is finished!
*)
unit TestCalc;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, MCalc, TreeView;
type
{this is a class derived from the pure TCalcThread, so it's easy to get result
of the calculation }
Calculator=class(TCalcThread)
private
procedure UpdateResult; override; {redefine the update res}
end;
TForm1 = class(TForm)
Button1: TButton;
Edit1: TEdit;
procedure Button1Click(Sender: TObject);
private
public
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure Calculator.UpdateResult;
begin
inherited; {call the previous version !!! you must do it}
MessageDlg('Result: '+CalcStrResult+Chr(10)+Chr(13)+'Error: '+RaisedError,mtInformation,[mbOk],0);
{show the result!}
end;
procedure TForm1.Button1Click(Sender: TObject);
var
Variables: PNode;
begin
{create a variable tree, you may do this once for a global variable tree and each
time you launch another calc reuse it, so variables will be kept}
New(Variables,Create(NodeVariable,'Variable Tree (private):'));
{create the inherited calculator thread, UpdateResult will be called as
the calculation is finished}
Calculator.Create(Edit1.Text,Variables,Deg,0);
end;
end.